## setup ##

# clean environment
rm(list=ls())

# load packages
library(sandwich)
library(lmtest)

# load data
dat <- read.csv2("data_experiment_covariates_csv.csv",
                encoding = 'UTF-8')


## regressions of treatment on covariates ##

# OLS
mod_immi <- lm(immback ~ east + migrant + female + age + day, data=dat)
mod_part <- lm(partisan ~ east + migrant + female + age + day, data=dat)

# robust standard errors
mod_immi_rob <- coeftest(mod_immi, vcov = vcovHC(mod_immi, "HC1"))
mod_part_rob <- coeftest(mod_part, vcov = vcovHC(mod_part, "HC1"))

# show coefficients and SEs
mod_immi_rob
mod_part_rob

# show f-statistic
summary(mod_immi)$fstatistic[1]
summary(mod_part)$fstatistic[1]
